AsyncCommand
Ecng.ComponentModel
Async delegate command capable of taking argument.
Herda de: NotifiableObject
Implementa: IRevalidatableCommand, ICommand, IDisposable
Construtores
AsyncCommand
public AsyncCommand(Func<T, CancellationToken, Task> execute, Func<T, bool> canExecute, bool allowMultipleExecution)
asyncCommand = AsyncCommand(execute, canExecute, allowMultipleExecution)
Creates a new async command.
- execute
- The async execution logic.
- canExecute
- The execution status logic.
- allowMultipleExecution
- Allow multiple concurrent executions.
AsyncCommand
public AsyncCommand(Func<T, Task> execute, Func<T, bool> canExecute, bool allowMultipleExecution)
asyncCommand = AsyncCommand(execute, canExecute, allowMultipleExecution)
Creates a new async command without cancellation support.
- execute
- The async execution logic.
- canExecute
- The execution status logic.
- allowMultipleExecution
- Allow multiple concurrent executions.
Propriedades
CancelCommand
public IRevalidatableCommand CancelCommand { get; }
value = asyncCommand.CancelCommand
Gets the command to cancel the current execution.
IsCancellationRequested
public bool IsCancellationRequested { get; }
value = asyncCommand.IsCancellationRequested
Gets whether cancellation has been requested.
IsExecuting
public bool IsExecuting { get; private set; }
value = asyncCommand.IsExecuting
asyncCommand.IsExecuting = value
Gets whether the command is currently executing.
Métodos
Dispose
public void Dispose()
asyncCommand.Dispose()
Disposes the command and cancels any pending operation.
Dispose
protected virtual void Dispose(bool disposing)
asyncCommand.Dispose(disposing)
Disposes the command resources.
- disposing
- True if disposing managed resources.
ExecuteAsync
public Task ExecuteAsync(T parameter)
result = asyncCommand.ExecuteAsync(parameter)
Executes the command asynchronously.
- parameter
- The command parameter.
Retorna: A task representing the async operation.
RaiseCanExecuteChanged
public void RaiseCanExecuteChanged()
asyncCommand.RaiseCanExecuteChanged()
Invoke CanExecuteChanged event.
Eventos
CanExecuteChanged
public event EventHandler CanExecuteChanged
asyncCommand.CanExecuteChanged += handler